package com.sto.stoapp.adapter;

import java.util.List;

import com.sto.stoapp.activity.R;
import com.sto.stoapp.entity.BillcodeEntity;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class BillcodeTableAdapter extends BaseAdapter {

	private List<BillcodeEntity> entitys;
	private Context mContext;
	public BillcodeTableAdapter(Context context,List<BillcodeEntity> entitys){
		this.mContext=context;
		this.entitys=entitys;
	}
	@Override
	public int getCount() {
	
		return entitys.size();
	}

	@Override
	public Object getItem(int position) {
	
		return entitys.get(position);
	}

	@Override
	public long getItemId(int position) {
	
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		Holder holder;
		if (view == null) {
			holder = new Holder();
			view = LayoutInflater.from(mContext).inflate(
					R.layout.sto_billcode_item, null);
			holder.name = (TextView) view
					.findViewById(R.id.sitename);
			holder.billcodebegin = (TextView) view
					.findViewById(R.id.billcodebegin);
			holder.billcodeend = (TextView) view
					.findViewById(R.id.billcodeend);
			view.setTag(holder);
		} else {
			holder = (Holder) view.getTag();
		}
		holder.name.setText(entitys.get(position).getSiteName());
		holder.billcodebegin.setText(entitys.get(position).getBillcodeBegin());
		holder.billcodeend.setText(entitys.get(position).getBillcodeEnd());
		return view;
	}
	class Holder {
		TextView name;
		TextView billcodebegin;
		TextView billcodeend;
	}
}
